package com.ph.irp.base.assistantmaterial.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.ph.irp.base.assistantmaterial.service.AssistantmaterialIndustryService;
import com.ph.irp.model.PBaseAssistantmaterialIndustry;
/**
 * 行业Action
 * @author Administrator
 *
 */
public class AssistantmaterialIndustryAction extends ActionSupport {
	private PBaseAssistantmaterialIndustry pbaseassistantmaterialIndustryModel = null;
	private List<PBaseAssistantmaterialIndustry> pbaseassistantmaterialIndustryList = null;
	private AssistantmaterialIndustryService assistantmaterialIndustryService = null;
	private static String FORWORD = null;
	//接收选中复选框传递的数据
	private Object[] rowlist = null ;
	public String getIndustryByCondition() throws Throwable {
		if(pbaseassistantmaterialIndustryModel == null){
			pbaseassistantmaterialIndustryList = assistantmaterialIndustryService.getAllAssistantmaterialIndustry();
			
		}
		else if(!pbaseassistantmaterialIndustryModel.getIndustryCode().trim().equals("") && pbaseassistantmaterialIndustryModel.getIndustryName().trim().equals("") ){
			pbaseassistantmaterialIndustryList = assistantmaterialIndustryService.getAllAssistantmaterialIndustryByCode(pbaseassistantmaterialIndustryModel.getIndustryCode().trim());
		}
		
		else if(!pbaseassistantmaterialIndustryModel.getIndustryName().trim().equals("") && pbaseassistantmaterialIndustryModel.getIndustryCode().trim().equals("") ){
			pbaseassistantmaterialIndustryList = assistantmaterialIndustryService.getAllAssistantmaterialIndustryByName(pbaseassistantmaterialIndustryModel.getIndustryName().trim());
		}
		else if(!pbaseassistantmaterialIndustryModel.getIndustryCode().trim().equals("") && !pbaseassistantmaterialIndustryModel.getIndustryName().trim().equals("")){
			pbaseassistantmaterialIndustryList = assistantmaterialIndustryService.getAllAssistantmaterialIndustryByCodeAndName(pbaseassistantmaterialIndustryModel.getIndustryCode().trim(),pbaseassistantmaterialIndustryModel.getIndustryName().trim());
		}
		else{
			pbaseassistantmaterialIndustryList = assistantmaterialIndustryService.getAllAssistantmaterialIndustry();
		}
		this.pbaseassistantmaterialIndustryModel = null;
		return "success";
	}
	public String showIndustryList() throws Throwable {	
		pbaseassistantmaterialIndustryList = assistantmaterialIndustryService.getAllAssistantmaterialIndustry();
		pbaseassistantmaterialIndustryModel = null;
		return "success";
	}
	public String addIndustry() throws Throwable{
			assistantmaterialIndustryService.addAssistantmaterialIndustry(pbaseassistantmaterialIndustryModel);
		    this.pbaseassistantmaterialIndustryModel = null;
			 return "success";
	}
	public String editIndustry() throws Throwable{
		this.assistantmaterialIndustryService.updateAssistantmaterialIndustry(pbaseassistantmaterialIndustryModel);
		pbaseassistantmaterialIndustryModel = null;
		return "success";
	}
	public String showEditIndustry() throws Throwable{
	
		Integer industryID = Integer.valueOf((String) rowlist[0]);	
		pbaseassistantmaterialIndustryModel = assistantmaterialIndustryService.getAssistantmaterialIndustryById(industryID);
		rowlist=null;
		return "success" ;
	}
	public String deleteIndustry() throws Throwable{
		assistantmaterialIndustryService.deleteAssistantmaterialIndustry(rowlist) ;	
		return "success" ;
	}
	public String selectIndustry() throws Throwable {
	return this.getIndustryByCondition();

	}
	
	public PBaseAssistantmaterialIndustry getPbaseassistantmaterialIndustryModel() {
		return pbaseassistantmaterialIndustryModel;
	}
	public void setPbaseassistantmaterialIndustryModel(
			PBaseAssistantmaterialIndustry pbaseassistantmaterialIndustryModel) {
		this.pbaseassistantmaterialIndustryModel = pbaseassistantmaterialIndustryModel;
	}
	public List<PBaseAssistantmaterialIndustry> getPbaseassistantmaterialIndustryList() {
		return pbaseassistantmaterialIndustryList;
	}
	public void setPbaseassistantmaterialIndustryList(
			List<PBaseAssistantmaterialIndustry> pbaseassistantmaterialIndustryList) {
		this.pbaseassistantmaterialIndustryList = pbaseassistantmaterialIndustryList;
	}
	public AssistantmaterialIndustryService getAssistantmaterialIndustryService() {
		return assistantmaterialIndustryService;
	}

	public void setAssistantmaterialIndustryService(
			AssistantmaterialIndustryService assistantmaterialIndustryService) {
		this.assistantmaterialIndustryService = assistantmaterialIndustryService;
	}

	public static String getFORWORD() {
		return FORWORD;
	}
	
	public static void setFORWORD(String forword) {
		FORWORD = forword;
	}
	
	public Object[] getRowlist() {
		return rowlist;
	}
	
	public void setRowlist(Object[] rowlist) {
		this.rowlist = rowlist;
	}
	
}
